#!/usr/bin/env python
PACKAGE = "roboteq_control"

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()

#from 250
# to check PLIN - pulse linearity [pag. 299]

# PMOD [pag. 302]
conversion_type = gen.enum([ gen.const("conversion_disabled",          int_t, 0, "Disable pulse input"),
                             gen.const("pulse_with", int_t, 1, "Enable in pulse with mode"),
                             gen.const("frequency", int_t, 2, "Enable in frequency mode"),
                             gen.const("duty_cycle", int_t, 3, "Enable in duty cycle mode"),
                             gen.const("magsensor", int_t, 4, "Enable in magsensor mode"),],
                            "Type of pulse input conversion")
gen.add("conversion", int_t, 0, "Type of pulse input conversion", 0, 0, 4, edit_method=conversion_type)

# PINA [pag. 287]
input_use_type = gen.enum([ gen.const("input_disabled",  int_t, 0, "Disabled"),
		         gen.const("motor_command",  int_t, 1, "Motor command"),
                         gen.const("feedback", int_t, 2, "Feedback")],
                         "configuration")
gen.add("input_use", int_t, 0, "Configuration pulse input", 0, 0, 2, edit_method=input_use_type)
motor_enable = gen.enum([ gen.const("disabled",  int_t, 0, "Disabled"),
		         gen.const("enabled",  int_t, 1, "enabled")],
                         "Enable feedback from this motor")
gen.add("input_motor_one", int_t, 0, "Configuration pulse input", 0, 0, 2, edit_method=motor_enable)
gen.add("input_motor_two", int_t, 0, "Configuration pulse input", 0, 0, 2, edit_method=motor_enable)

# PPOL [pag. 303]
conversion_polarity_type = gen.enum([ gen.const("direct",  int_t, 0, "After gears"),
                    gen.const("inverse", int_t, 1, "Before gears")],
                    "Polarity conversion")
gen.add("conversion_polarity", int_t, 0, "Conversion pulse input", 1, 0, 1, edit_method=conversion_polarity_type)

# PDB [pag. 297]
gen.add("input_deadband",  int_t, 0, "[%] How the movement near to zero is considered zero",   0,  0, 50)

# PMIN [pag. 301]
gen.add("range_input_min",  double_t, 0, "[ms] Set the pulse input min",   1.0,  0, 65.536)

# PMAX [pag. 300]
gen.add("range_input_max",  double_t, 0, "[ms] Set the pulse input max",   2.0,  0, 65.536)

# PTCR [pag. 293]
gen.add("range_input_center",  double_t, 0, "[ms] Set the pulse input center",   1.5,  0, 65.536)

#Default command
gen.add("load_roboteq", bool_t  , 0, "Load all parameters from Roboteq board", False)
gen.add("restore_defaults", bool_t  , 0, "Restore to the original configuration", False      )

exit(gen.generate(PACKAGE, "roboteq_node", "RoboteqPulseInput"))
